import api from "../../api/mop";
import { err, toast } from "../../utils/wxapi";
Page({
  data: {
    workType: "",
  },
  async sub() {
    const { workType } = this.data;
    if (!workType) return toast("请输入标签名称");
    try {
      const res = await api.postwork_type({ workType });
      console.log(res);
      if (res.respCode === 200) {
        toast("添加成功");
        setTimeout((e) => {
          wx.navigateBack({ delta: 1 });
        }, 1000);
      } else {
        toast(res.msg);
      }
    } catch (error) {
      err(error);
    }
  },
});
